<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function() {
		$("#a")
				.toggle(
						function() {
							$
									.post(
											"${pageContext.request.contextPath}/showProduct",
											function(data) {
												var jsonobj = eval(data);
												if (jsonobj.type = 0) {
													alert(jsonobj.message);
												} else if (jsonobj.type = 1) {
													var obj = jsonobj.content;
												    var html = "<table border='1'><tr><td>编号</td><td>产品</td><td>数量</td><td>价钱</td></tr>"
													for (var i = 0; i < obj.length; i++) {
														html += "<tr><td>"
																+ obj[i].id
																+ "</td><td>"
																+ obj[i].name
																+ "</td><td>"
																+ obj[i].count
																+ "</td><td>"
																+ obj[i].price
																+ "</td></tr>";
													}
													html += "</table>";
													$("#d").html(html);
												}
											}, "json");
						}, function() {
							$("#d").html("");
						})

	});
</script>

</head>
<body>
	<a href="javascript:void(0)" id="a">查看商品信息</a>
	<div id="d"></div>

</body>
</html>